package hku.cs.lunuo.handlers;
import hku.cs.lunuo.views.RankView;

import java.io.File;

import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.commands.IHandler;
import org.eclipse.ui.handlers.HandlerUtil;


public class RankvRemove extends AbstractHandler implements IHandler {

	@Override
	public Object execute(ExecutionEvent event) throws ExecutionException {
		RankView viewer = (RankView)HandlerUtil.getActiveWorkbenchWindow(event)
				.getActivePage().findView(RankView.VIEW_ID);
		viewer.getRanks().clear();
		viewer.getTableViewer().setInput(viewer.getRanks());
		File f = new File(viewer.getCurrentRank());
		if(f.exists())
			f.delete();
		return null;
	}


}
